<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">


<title></title>
</head><body>
<h1>Printing with Samba</h1>
Some builds of Puppy do not have the 'smbspool' utility (type "which
smbspool" in a terminal to find out). Puppy developer "Patriot" (forum
name) advised of a special CUPS driver
script named 'smbc' is used, which in turn uses the 'smbclient' utility
to print. We found that worked, however Patriot went a big step further
and wrote a script named 'smb' that is a drop-in replacement for
'smbspool'. <br>
<br>
This help page is in two parts: the first part describes Patriots 'smb'
drop-in replacement for 'smbspool' (which is the recommended choice),
the second part describes the earlier 'smbc' script...<br>
<h2>PART 1: smbspool drop-in replacement</h2>
<span style="font-style: italic;">Extract from Forum post: </span><a style="font-style: italic;" href="http://www.murga-linux.com/puppy/viewtopic.php?t=57610">http://www.murga-linux.com/puppy/viewtopic.php?t=57610</a> <br>
<br>
<span class="postbody">Recently, BarryK enquired about samba-tng's
non-existent smbspool and whether printing through smbclient will work.
I've advised him that it is indeed possible to do raw/postcript
printing with smbclient and the smbc script (from <a href="http://willem.engen.nl/projects/cupssmb/" target="_blank" class="postlink">http://willem.engen.nl/projects/cupssmb/</a>) is what he can use or base upon.
<br>

<br>
I've taken a closer look at the whole smbspool thingy and have
scribbled a drop-in replacement script for smbspool by sending print
job(s) to smbclient. This script is loosely based on samba's smbspool
internal logics, uses smbspool input parameter format and attempts to
mimic smbspool behaviour. This script is designed to work with existing
CUPS device URI.
<br>

<br>
The device URI (Uniform Resource Identifier) format for smbspool is defined as:
<br>
<ul><span style="font-size: 14px; line-height: normal;"><span style="font-weight: bold;">smb://</span><span style="font-style: italic;">[username[:password]@][workgroup/]</span><span style="font-weight: bold;">server</span><span style="font-style: italic;">[:port]</span><span style="font-weight: bold;">/printer</span></span><br></ul>
Please take note of the compulsory minimum in bold: <span style="font-weight: bold;">smb://</span>   [username[:password]@]   [workgroup/]   <span style="font-weight: bold;">server</span>  [:port]  <span style="font-weight: bold;">/printer</span>
<br>

<br>
<span style="font-weight: bold;">Examples:</span>
<br>
<ul>1. smb://PRINTSERVER/HP4V <span style="color: darkblue;">(minimum parameter smb://server/printer)</span><br><br>
2. smb://192.168.1.2/ML1200 <span style="color: darkblue;">(same as #1 but using IP address)</span><br><br>
3. smb://zigbert:ladiesman217@/192.168.2.22:9191/MP250 <span style="color: darkblue;">(extended parameters with username, password and server port)</span><br><br>
4. smb://dogbert:majesty@SYHDP/DILBERT/LEDCOPIER <span style="color: darkblue;">(extended parameters with username, password and domain name)</span><br></ul>
</span><br>
<span class="postbody"><span style="font-weight: bold;">Features:</span>
<br>
- Fully supports smb URI format. This allows the authentication details to be embedded within the URI. 
<br>
- Allows printing to multiple authenticated servers without mucking with separate authentication files.
<br>
- Supports print copies option, if required.
<br>
- Supports smbclient from both samba and samba-tng.
<br>

<br>
<span style="font-weight: bold;">Manual installation:</span></span><span class="postbody"><span style="font-weight: bold;"> <span style="color: rgb(102, 0, 0);">[already installed in this Puppy]</span></span></span><span class="postbody"><span style="font-weight: bold;">&nbsp;</span>
<br>
1. Save the script as /usr/lib/cups/backend/smb.
<br>
2. Give it an owner only permission (# chmod 700
/usr/lib/cups/backend/smb). (If you skip this, smbclient will bork
reading smb.conf file)
<br>
3. Configure smb printer if required &amp; do a test print
<br>

<br>
<span style="font-weight: bold;">Final notes:</span>
<br>
- This script is designed to run on puppy &gt;= 4.0 platform with cups &gt;= 1.1.x.
<br>
- Development and testing is done on puppy412 with cups-1.3.11, samba-3.0.37 and samba-tng-0.5rc1
<br>
- and yes, if anyone's wondering, I am able to print raw/ps using either samba or samba-tng smbclient.
<br>

</span><br>
<br>
<hr style="width: 100%; height: 2px;"><br>
<h2>PART 2: Getting CUPS to work with Windows print servers</h2>


<span style="font-style: italic;">Extract from: </span><a style="font-style: italic;" href="http://willem.engen.nl/projects/cupssmb/">http://willem.engen.nl/projects/cupssmb/</a> <br style="font-style: italic;">
<span style="font-style: italic;">
by  Willem van Engen</span><br>

<br>
CUPS uses
<a href="http://www.samba.org/samba/docs/man/manpages-3/smbspool.8.html">smbspool(8)</a>
to print pages to windows servers. This did not appear to work, whereas printing with
<a href="http://www.samba.org/samba/docs/man/manpages-3/smbclient.1.html">smbclient(1)</a>
did (some relief). Wanting to get it working, I created a custom CUPS backend that uses
the latter instead of the former. This also allowed me to solve the problem of the
windows password being visible in the device uri (which is shown in the web interface).
<i>Note that this still is a work in progress: it is being used with success, but now
and then I encounter issues.</i> This page will be updated accordingly.

<p>Following are sections for using the aforementioned programs. The final section
gives a possible solution for using windows print servers with CUPS when smbspool(8)
isn't working.</p>



<h3>Printing with smbspool</h3>



<p>A CUPS <a href="http://www.cups.org/documentation.php/man-backend.html">backend(7)</a>
is a program, usually located in <tt>/usr/lib/cups/backend/</tt>,
that sends a job to a printer or print server. 
CUPS uses smbspool(8), which is part of <a href="http://www.samba.org/">samba</a>,
to spool jobs to windows servers. To this end, there is a symbolic link from
<tt>/usr/lib/cups/backend/smb</tt> to <tt>/usr/bin/smbspool</tt>.</p>


<p>To test the backend, it is possible to invoke smbspool(8) by hand. For example:</p>

<pre style="margin-left: 2em;">DEVICE_URI="smb://server/printer" smbspool 1234 me sometitle 1 &lt;test.ps</pre>



<h3>Printing with smbclient</h3>



<p>It is also possible to use smbclient(1) to print. When logging into a printer share
on a windows server, one can issue the <tt>print</tt> command to print a file. For example:</p>

<pre style="margin-left: 2em;"><b>smbclient -W <i>Domain</i> -U <i>me</i> <i>//server/printer</i></b><br>Added interface ip=<i>xxx.xxx.xxx.xxx</i> bcast=<i>xxx.xxx.xxx.xxx</i> nmask=<i>xxx.xxx.xxx.xxx</i><br>Password: <b><i>password</i></b><br>Domain=[<i>Domain</i>] OS=[<i>Windows Server 2003 3790 Service Pack 2</i>] Server=[<i>Windows Server 2003 5.2</i>]<br>smb: \&gt; <b>print <i>test.ps</i></b><br>printing file <i>test.ps</i> as <i>test.ps</i><br><i>xxxxx</i> bytes printed<br><br>smb: \&gt; <b>quit</b><br></pre>



<h3>A CUPS backend using smbclient</h3>



<p>When smbspool(8) doesn't work, it may be possible to get printing working with smbclient(1) instead.
This can be done by adding a custom CUPS backend. Download the file
<tt>smbc</tt>, save it as
<tt>/usr/lib/cups/backend/smbc</tt> and make it executable. Make sure to make it owned by
root.<span style="color: rgb(51, 0, 0);"> <span style="color: rgb(102, 0, 0); font-weight: bold;">[NOTE: this script is already in Puppy]</span></span><br>
</p>


<p>You should still create the file <tt>/etc/samba/printing.auth</tt> containing your
windows credentials, like this:</p>

<pre style="margin-left: 2em;">username = s<i>123456</i><br>password = <i>mypassword</i><br>domain   = TUE<br></pre>

<p>To protect it from prying eyes, make it owned by user <tt>cupsys</tt> (or whatever
CUPS backends are run by on your system) and make it readable for that user only. For
<a href="http://www.ubuntu.com/">Ubuntu</a> users: this user is <tt>cupsys</tt> on Feisty,
but <tt>lp</tt> on Gutsy.</p>


<p>Remains to setup CUPS. I recommend to add a printer using the
<a href="http://localhost:631/">web interface</a>
with a device uri with protocol <tt>smbc</tt>, like
<tt>smbc://physfp.phys.tue.nl/n-IS2060PS</tt></p>


<p>If you happen to use <a href="http://en.opensuse.org/Apparmor">AppArmor</a> in enforcing mode,
you'll need to add <tt>#include &lt;abstractions/samba&gt;</tt> to the <tt>cupsd</tt>
profile.</p>


<br>
<small>This page composed by Barry Kauler July 2010</small><br>
</body></html>